<!--
 * @Author: zhangpeng
 * @Date: 2024-11-25 15:09:35
 * @FilePath: \scientific_research_manager_web\src\views\resultsManagement\components\Horizontal\index.vue
 * @LastEditTime: 2025-01-08 14:13:27
 * @Description: 成果-横向项目/管理 - 列表
-->
<script setup lang="ts">
import { onMounted, ref, computed } from 'vue'
import { ElMessage } from 'element-plus'
import useUserStore from '@/store/modules/user'
import ResultAttachmentModal from '../ResultAttachmentModal.vue'
import { StatusColorMap, StatusMap } from '@/utils/constText'
import { resultStatusEnum, dictEnum } from '@/utils/constEnum'
import { downloadFile } from '@/utils/download'
import { deleteResultsManagementApi, approveResultsManagementApi, approveBatchResultsManagementApi } from '@/api/resultsManagement'
import { getHorizontalListApi, exportHorizontalApi } from '@/api/resultsManagement/horizontalApi'
import  { PaginationQueryUniteRespDTO, AppStateChangeRespDTO } from '@/types/index'
import  { HorizontalPageVO, AttachmentFileInfoDTO } from '@/types/resultsManagement'
import formateDate from '@/utils/formateDate';

const props = defineProps({
  /* 模块类型：college 学院成果管理；office 科研处成果管理；mine 我的成果； */
  moduleType: {
    type: String as PropType<'college' | 'office' | 'mine'>,
    default: 'college',
  },
})
const route = useRoute()
const status = computed(() => {
	return Number(route.query.status) || undefined
})
const hasRejectPermi = computed(() => useUserStore().permissions?.includes('achievementReward:office:office-horizontal:reject'))
const { proxy } = getCurrentInstance()

const dict = proxy.useDict(dictEnum.department,dictEnum.horizontalContractType);
const searchBarRef = ref()

// 搜索条件组件配置数据
const conditionComponents = computed(() => {
  // college 
  const arr0 = [
    {
      type: 0,
      key: 'codeOrName',
      placeholder: '请输入工号',
    },
    {
      type: 0,
      key: 'projectCodeOrName',
      placeholder: '请输入项目编号/项目名称',
    },
    {
      type: 2,
      key: 'statisticalYearArray',
      width: '456px',
      config: {
        startPlaceholder: '请选择统计年度开始时间',
        endPlaceholder: '请选择统计年度结束时间',
        type: "yearrange",
        valueFormat: 'YYYY',
      }
    },
    {
      type: 1,
      key: 'projectTypeId',
      placeholder: '合同类别',
      config: {
        options: dict[dictEnum.horizontalContractType] || [],
      }
    },
    {
      type: 0,
      key: 'client',
      placeholder: '委托单位',
    },

    {
      type: 2,
      key: 'businessDateArray',
      config: {
        startPlaceholder: '请选择合同签订日期开始时间',
        endPlaceholder: '请选择合同签订日期结束时间',
      },
      width: '456px'
    },
   

    {
      type: 1,
      key: 'status',
      cValue: status.value,
      placeholder: '状态',
      config: {
        options: [
          { title: StatusMap[resultStatusEnum.resultWaitCollegeAudit], value: resultStatusEnum.resultWaitCollegeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegePassWaitOfficeAudit], value: resultStatusEnum.resultCollegePassWaitOfficeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegeUnPass], value: resultStatusEnum.resultCollegeUnPass },
          { title: StatusMap[resultStatusEnum.resultOfficeUnPass], value: resultStatusEnum.resultOfficeUnPass },
          { title: StatusMap[resultStatusEnum.resultSign], value: resultStatusEnum.resultSign },
        ]
      }
    },
    
  ]
  // office
  const arr1 = [
    {
      type: 1,
      key: 'departmentId',
      placeholder: '所属院校（部）',
      config: {
        options: dict[dictEnum.department],
      }
    },
    {
      type: 0,
      key: 'codeOrName',
      placeholder: '请输入工号',
    },
    {
      type: 0,
      key: 'projectCodeOrName',
      placeholder: '请输入项目编号/项目名称',
    },
    {
      type: 2,
      key: 'statisticalYearArray',
      width: '456px',
      config: {
        startPlaceholder: '请选择统计年度开始时间',
        endPlaceholder: '请选择统计年度结束时间',
        type: "yearrange",
        valueFormat: 'YYYY',
      }
    },
    {
      type: 1,
      key: 'projectTypeId',
      placeholder: '合同类别',
      config: {
        options: dict[dictEnum.horizontalContractType] || [],
      }
    },
    {
      type: 0,
      key: 'client',
      placeholder: '委托单位',
    },

    {
      type: 2,
      key: 'businessDateArray',
      config: {
        startPlaceholder: '请选择合同签订日期开始时间',
        endPlaceholder: '请选择合同签订日期结束时间',
      },
      width: '456px'
    },
   

    {
      type: 1,
      key: 'status',
      cValue: status.value,
      placeholder: '状态',
      config: {
        options: [
          { title: StatusMap[resultStatusEnum.resultWaitCollegeAudit], value: resultStatusEnum.resultWaitCollegeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegePassWaitOfficeAudit], value: resultStatusEnum.resultCollegePassWaitOfficeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegeUnPass], value: resultStatusEnum.resultCollegeUnPass },
          { title: StatusMap[resultStatusEnum.resultOfficeUnPass], value: resultStatusEnum.resultOfficeUnPass },
          { title: StatusMap[resultStatusEnum.resultSign], value: resultStatusEnum.resultSign },
        ]
      }
    },
    
  ]
  //  mine
  const arr2 = [
    {
      type: 0,
      key: 'name',
      placeholder: '请输入项目名称',
    },
    {
      type: 1,
      key: 'status',
      placeholder: '请选择',
      config: {
        options: [
          { title: StatusMap[resultStatusEnum.resultWaitSubmit], value: resultStatusEnum.resultWaitSubmit },
          { title: StatusMap[resultStatusEnum.resultWaitCollegeAudit], value: resultStatusEnum.resultWaitCollegeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegePassWaitOfficeAudit], value: resultStatusEnum.resultCollegePassWaitOfficeAudit },
          { title: StatusMap[resultStatusEnum.resultCollegeUnPass], value: resultStatusEnum.resultCollegeUnPass },
          { title: StatusMap[resultStatusEnum.resultOfficeUnPass], value: resultStatusEnum.resultOfficeUnPass },
          { title: StatusMap[resultStatusEnum.resultSign], value: resultStatusEnum.resultSign },
        ]
      }
    },
  ]

  if (props.moduleType === 'college') {
    return arr0
  } else if (props.moduleType === 'office') {
    return arr1
  } else {
    return arr2
  }
})

// 表头
const columns = computed(() => {
  // college  office
  const arr1 = [
    {
      title: '序号',
      width: 48,
      dataIndex: 'index',
      slotName: 'index',
      
    },

    {
      title: '学院（部）',
      minWidth: 50,
      dataIndex: 'departmentName',
      slotName: 'departmentName',
      
    },
    {
      title: '工号',
      minWidth: 40,
      dataIndex: 'accountCode',
      slotName: 'accountCode',
      
    },
    {
      title: '姓名',
      minWidth: 40,
      dataIndex: 'accountName',
      slotName: 'accountName',
      
    },
    {
      title: '项目编号',
      minWidth: 40,
      dataIndex: 'projectCode',
      slotName: 'projectCode',
      
    },
    {
      title: '项目名称',
      minWidth: 170,
      dataIndex: 'name',
      slotName: 'name',
      
    },
    {
      title: '合同类别',
      minWidth: 40,
      dataIndex: 'projectType',
      slotName: 'projectType',
      
    },
    {
      title: '委托单位',
      minWidth: 40,
      dataIndex: 'client',
      slotName: 'client',
      
    },
    {
      title: '经费（万元）',
      minWidth: 40,
      dataIndex: 'funds',
      slotName: 'funds',
      
    },
    {
      title: '合同签订日期',
      minWidth: 50,
      dataIndex: 'businessDate',
      slotName: 'businessDate',
      
    },
    {
      title: '科研分',
      minWidth: 30,
      dataIndex: 'researchScore',
      slotName: 'researchScore',
      
    },
    {
      title: '统计年度',
      minWidth: 40,
      dataIndex: 'statisticalYear',
      slotName: 'statisticalYear',
      
    },
    {
      title: '附件',
      minWidth: 40,
      dataIndex: 'fileList',
      slotName: 'fileList',
      
    },
    {
      title: '状态',
      minWidth: 40,
      dataIndex: 'status',
      slotName: 'status',
      
    },
    {
      title: '操作',
      minWidth: 80,
      dataIndex: 'option',
      slotName: 'option',

    }
  ]

  // mine
  const arr2 = [
    {
      title: '序号',
      width: 48,
      dataIndex: 'index',
      slotName: 'index',
      
    },
    {
      title: '项目编号',
      minWidth: 40,
      dataIndex: 'projectCode',
      slotName: 'projectCode',
      
    },
    {
      title: '项目名称',
      minWidth: 180,
      dataIndex: 'name',
      slotName: 'name',
      
    },
    {
      title: '合同类别',
      minWidth: 40,
      dataIndex: 'projectType',
      slotName: 'projectType',
      
    },
    {
      title: '委托单位',
      minWidth: 40,
      dataIndex: 'client',
      slotName: 'client',
      
    },
    {
      title: '经费（万元）',
      minWidth: 40,
      dataIndex: 'funds',
      slotName: 'funds',
      
    },
    {
      title: '合同签订日期',
      minWidth: 50,
      dataIndex: 'businessDate',
      slotName: 'businessDate',
      
    },
    {
      title: '科研分',
      minWidth: 30,
      dataIndex: 'researchScore',
      slotName: 'researchScore',
      
    },
    {
      title: '统计年度',
      minWidth: 40,
      dataIndex: 'statisticalYear',
      slotName: 'statisticalYear',
      
    },
    {
      title: '状态',
      minWidth: 40,
      dataIndex: 'status',
      slotName: 'status',
      
    },
    {
      title: '操作',
      minWidth: 80,
      dataIndex: 'option',
      slotName: 'option',
    }
  ]

  if (props.moduleType === 'college') {
    return arr1
  } else if (props.moduleType === 'office') {
    return arr1
  } else {
    return arr2
  }
})

const router = useRouter();
// 用户信息
const userStore = useUserStore()

// 列表数据
const dataList = ref<HorizontalPageVO[]>([])
// 数据总条数
const total = ref(0)
// 展示搜索条件组件框
const showSearch = ref(true)
const selectRowIds = ref<string[]>([])
const batchAudit = ref(false) //  批量审核
// 当前选中数据行坐标
const currentRow = ref()
const showDelModal = ref(false) //  删除弹框
const showAuditModal = ref(false) //  审核弹框
const showSubmitModal = ref(false) // 显示提交弹框
const showRepulseModal = ref(false) //  打回弹框
const showRecordDrawer = ref(false) //  审核记录弹框
const showAttachmentModal = ref(false)  //  附件弹框

// 表格loading
const tableLoading = computed(() => { return loading.value || deleteLoading.value || approveLoading.value || approveBatchLoading.value })

// 请求参数
const parameters = ref({
  page: 1,
  size: 20,
  unStatus: computed(() => { return props.moduleType !== 'mine' ? 0 : undefined }),
  createdBy: computed(() => { return props.moduleType === 'mine' ? userStore.id  : undefined }),
  departmentId: computed(() => { return props.moduleType === 'college' ? userStore.departmentId  : undefined }),
  // businessDateArray: undefined,
  // statisticalYearArray: undefined,
  businessStartDate: undefined,
  businessEndDate: undefined,
  statisticalStartYear: undefined,
  statisticalEndYear: undefined,
  codeOrName: undefined,
  projectCodeOrName: undefined,
  projectTypeId: undefined,
  client: undefined,
  status: status.value,
  name: undefined,
})
// 导出参数
const downloadParameters = ref({
  unStatus: computed(() => { return props.moduleType !== 'mine' ? 0 : undefined }),
  createdBy: computed(() => { return props.moduleType === 'mine' ? userStore.id : undefined }),
  departmentId: computed(() => { return props.moduleType === 'college' ? userStore.departmentId : undefined }), // 学院（部
  idList: []
})

/* 查询横向项目列表 */
const { run: getDataList, loading } = useRequest(getHorizontalListApi, {
  // false 为自动执行
  manual: true,
  debounceWait: 500,
  // 请求成功
  onSuccess: (response: PaginationQueryUniteRespDTO<HorizontalPageVO>) => {
    if (response.content) {
      dataList.value = response.content
    }else{
      dataList.value = []
    }
    total.value = response.totalElements || 0;
  },
  // 请求失败
  onError: () => {
  },
})

/* 删除横向项目成果 */
const { run: deleteResults, loading: deleteLoading } = useRequest(deleteResultsManagementApi, {
  // false 为自动执行
  manual: true,
  debounceWait: 500,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO) => {
     if (response.isSuccess) {
      ElMessage({
        message: '删除成功!',
        type: 'success',
        plain: true,
      })
      currentRow.value = {}
      refreshTableData(searchBarRef.value?.params)
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 成果审核 */
const { run: approveResults, loading: approveLoading } = useRequest(approveResultsManagementApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO, _params) => {
    if (response.isSuccess) {
      const _paramsStatus = _params?.[0]?.status
      // 提交审核
      if (_paramsStatus === resultStatusEnum.resultWaitCollegeAudit) {
        ElMessage({
          message: '提交成功!',
          type: 'success',
          plain: true,
        })
      } else if (_paramsStatus === resultStatusEnum.resultCollegePassWaitOfficeAudit || _paramsStatus === resultStatusEnum.resultSign) {
        ElMessage({
          message: '审核通过!',
          type: 'success',
          plain: true,
        })
      } else if (_paramsStatus === resultStatusEnum.resultCollegeUnPass || _paramsStatus === resultStatusEnum.resultOfficeUnPass) {
        ElMessage({
          message: '审核不通过!',
          type: 'success',
          plain: true,
        })
      } else if (_paramsStatus === resultStatusEnum.resultWaitSubmit) {
        ElMessage({
          message: '打回成功!',
          type: 'success',
          plain: true,
        })
      }
      currentRow.value = {}
      refreshTableData(searchBarRef.value?.params)
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 成果批量审核 */
const { run: approveBatchResults, loading: approveBatchLoading } = useRequest(approveBatchResultsManagementApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO, _params) => {
    if (response.isSuccess) {
      const _paramsStatus = _params?.[0]?.status
      if (_paramsStatus === resultStatusEnum.resultCollegePassWaitOfficeAudit || _paramsStatus === resultStatusEnum.resultSign) {
        ElMessage({
          message: '审核通过!',
          type: 'success',
          plain: true,
        })
      } else if (_paramsStatus === resultStatusEnum.resultCollegeUnPass || _paramsStatus === resultStatusEnum.resultOfficeUnPass) {
        ElMessage({
          message: '审核不通过!',
          type: 'success',
          plain: true,
        })
      }
      batchAudit.value = false
      refreshTableData(searchBarRef.value?.params)
    }
  },
  // 请求失败
  onError: () => {
  },
  onFinally: () => {
    batchAudit.value = false
  },
})

// 刷新列表
const refreshTableData = (params) => {
  parameters.value = { ...parameters.value, ...params }
  parameters.value = {
    ...parameters.value,
    businessStartDate: (params.businessDateArray ? params.businessDateArray[0] : undefined),
    businessEndDate: (params.businessDateArray ? params.businessDateArray[1] : undefined),
    statisticalStartYear: (params.statisticalYearArray ? params.statisticalYearArray[0] : undefined),
    statisticalEndYear: (params.statisticalYearArray ? params.statisticalYearArray[1] : undefined),
  }
  getDataList(parameters.value)
}

/* 导出列表数据 */
const { runAsync: exportFile } = useRequest(exportHorizontalApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: () => {
  },
  // 请求失败
  onError: () => {
  },
})
// 导出
const exportListData = async (params) => {
  downloadParameters.value.idList = params
  const res = await exportFile({
    ...downloadParameters.value,
    ...searchBarRef.value.params,
    businessStartDate: (parameters.value.businessDateArray ? parameters.value.businessDateArray[0] : undefined),
    businessEndDate: (parameters.value.businessDateArray ? parameters.value.businessDateArray[1] : undefined),
    statisticalStartYear: (parameters.value.statisticalYearArray ? parameters.value.statisticalYearArray[0] : undefined),
    statisticalEndYear: (parameters.value.statisticalYearArray ? parameters.value.statisticalYearArray[1] : undefined),
  })
  downloadFile(res)
}

// 表格行checked
const tableSelectRow = (ids: string[]) => {
  selectRowIds.value = ids
}

// 新增
const addEvent = () => {
  router.push({
    name: 'mine-horizontal-detail',
    query: {}
  })
}

// 提交弹框
const submitEvent = (record: HorizontalPageVO) => {
  currentRow.value = record
  showSubmitModal.value = true
}

 // 提交
const submitOkHandelEvent = () => {
  showSubmitModal.value = false
  approveResults({
    id: currentRow.value?.id ,
    status: resultStatusEnum.resultWaitCollegeAudit,
  })
}

// 详情
const detailEvent = (record: HorizontalPageVO) => {
  router.push({
    name: (props.moduleType === 'college' ? 'college-horizontal-detail' : (props.moduleType === 'office' ? 'office-horizontal-detail' : 'mine-horizontal-detail')),
    query: { id: record.id, mode: 'preview' }
  })

}
// 编辑
const editEvent = (record: HorizontalPageVO) => {
  router.push({
    name: (props.moduleType === 'college' ? 'college-horizontal-detail' : (props.moduleType === 'office' ? 'office-horizontal-detail' : 'mine-horizontal-detail')),
    query: { id: record.id, mode: 'edit' }
  })
}

// 删除弹框
const deleteAlertEvent = (record: HorizontalPageVO) => {
  currentRow.value = record
  showDelModal.value = true
}

// 删除数据行
const deleteOkHandle = () => {
  showDelModal.value = false
  deleteResults({ id: currentRow.value?.id })
}

// 审核弹框
const auditEvent = (record: HorizontalPageVO) => {
  currentRow.value = record
  showAuditModal.value = true
}


// 批量审核弹框
const batchAuditEvent = () => {
  if (!selectRowIds.value?.length) {
    return ElMessage({
      message: '未选择成果',
      type: 'error',
    })
  }
  batchAudit.value = true
  showAuditModal.value = true
}

// 审核通过
const auditOkHandle = (form: { auditMessage?: string }) => {
  showAuditModal.value = false
  if (batchAudit.value) {
    // 批量审核
    approveBatchResults({
      ids: selectRowIds.value,
      status: props.moduleType === 'college' ? resultStatusEnum.resultCollegePassWaitOfficeAudit : resultStatusEnum.resultSign,
      description: form?.auditMessage,
    })
  } else {
    approveResults({
      id: currentRow.value?.id,
      status: props.moduleType === 'college' ? resultStatusEnum.resultCollegePassWaitOfficeAudit : resultStatusEnum.resultSign,
      description: form?.auditMessage,
    })
  }
}

// 审核不通过
const auditCancelHandle = (form: { auditMessage?: string }) => {
  showAuditModal.value = false
  if (batchAudit.value) {
    // 批量审核
    approveBatchResults({
      ids: selectRowIds.value,
      status: props.moduleType === 'college' ? resultStatusEnum.resultCollegeUnPass : resultStatusEnum.resultOfficeUnPass,
      description: form?.auditMessage,
    })
  } else {
    approveResults({
      id: currentRow.value?.id,
      status: props.moduleType === 'college' ? resultStatusEnum.resultCollegeUnPass : resultStatusEnum.resultOfficeUnPass,
      description: form?.auditMessage,
    })
  }

}

// 打回弹框
const repulseEvent = (record: HorizontalPageVO) => {
  currentRow.value = record
  showRepulseModal.value = true
}
// 打回
const repulseOkHandle = (form: { repulseMessage?: string }) => {
  showRepulseModal.value = false
  approveResults({
    id: currentRow.value?.id,
    status: resultStatusEnum.resultWaitSubmit,
    description: form?.repulseMessage,
  })
}

// 审核记录
const recordEvent = (record: HorizontalPageVO) => {
  currentRow.value = record
  showRecordDrawer.value = true
}

const attachmentFileList = ref<{ title: string, files?: AttachmentFileInfoDTO[] }[]>([])   //  选中行附件
// 附件
const attachmentEvent = (record: HorizontalPageVO) => {
  const attachments = [
    {
      title: '合同',
      files: record?.contractFileList,
    },
    {
      title: '到账凭证',
      files: record?.receiptVoucherFileList,
    },
    {
      title: '其他附件',
      files: record?.fileList
    }
  ]
  attachmentFileList.value = attachments
  showAttachmentModal.value = true
}


onMounted(() => {
  getDataList(parameters.value)
})

</script>

<template>
  <div>
    <div v-if="showSearch" style="padding: 16px 20px;margin-bottom: 16px;border-radius: 4px;background-color: white;">
      <SearchBar :components="conditionComponents" :hideRightArea="false"  ref="searchBarRef"
        @search="refreshTableData" />
    </div>
    <div style="padding: 16px 20px;padding-top: 0px;background-color: white;">
      <TableForm :data="dataList" :columns="columns"
        :tableLoading="tableLoading" :total-count="total" v-model:showSearch="showSearch" :showRowSelection="true"
        :show-tool-bar="true" :hideLeftMenu="props.moduleType !== 'mine'" btn-title="新增"
        :right-first-btn-permission="['mine:mine-horizontal:export', 'achievementReward:college:college-horizontal:export', 'achievementReward:office:office-horizontal:export']"
        @btn-click="addEvent"
        :download="(params) => { exportListData(params)}" @refresh="refreshTableData" @select-rows="tableSelectRow"
      >
        <template #leftMenu>
          <el-button v-if="props.moduleType === 'mine'" type="primary" @click="addEvent" v-hasPermi="['mine:mine-horizontal:add']">新增</el-button>
          <el-button v-else-if="props.moduleType === 'office'" type="primary" @click="batchAuditEvent" v-hasPermi="['achievementReward:office:office-horizontal:batchAudit']">批量审核</el-button>
          <el-button v-else-if="props.moduleType === 'college'" type="primary" @click="batchAuditEvent" v-hasPermi="['achievementReward:college:college-horizontal:batchAudit']">批量审核</el-button>
        </template>
        <template #index="{ rowIndex }">
          {{ rowIndex + 1 }}
        </template>

         <!-- 合同签订日期 -->
         <template #businessDate="{ record }">
          <span>{{ (record?.businessDate ? formateDate(record?.businessDate).format('YYYY-MM-DD') : '') }}</span>
        </template>
        <template #status="{ record }">
          <div class="status-box">
            <div class="status-dot"
              :style="`background-color: ${StatusColorMap[record.status as keyof typeof StatusColorMap]}`" />
            <div class="status-text" :style="`color: ${StatusColorMap[record.status as keyof typeof StatusColorMap]}`">{{ StatusMap[record.status as keyof typeof StatusMap] }}</div>
          </div>
        </template>
        
        <!-- 附件 -->
        <template #fileList="{ record }">
          <a class="btn-text" @click="attachmentEvent(record)" @dblclick.stop>点击查看</a>
        </template>

        <template #option="{ record }">
          <div class="optionClass">
            <!-- 个人 -->
            <template v-if="props.moduleType === 'mine'">
              <el-button v-if="record.status === resultStatusEnum.resultWaitSubmit" link type="primary"
                @click="submitEvent(record)" @dblclick.stop v-hasPermi="['mine:mine-horizontal:submit']">提交</el-button>
              <el-button link type="primary" @click="detailEvent(record)" v-hasPermi="['mine:mine-horizontal:detail']">详情</el-button>
              <!-- 待提交 / 学院|科研审核不通过显示编辑 -->
              <el-button
                v-if="record.status === resultStatusEnum.resultWaitSubmit || record.status === resultStatusEnum.resultOfficeUnPass || record.status === resultStatusEnum.resultCollegeUnPass"
                link type="primary" @click="editEvent(record)" @dblclick.stop v-hasPermi="['mine:mine-horizontal:edit']">
                编辑</el-button>
              <!-- 待提交 / 学院|科研审核不通过显示删除 -->
              <el-button
                v-if="record.status === resultStatusEnum.resultWaitSubmit || record.status === resultStatusEnum.resultOfficeUnPass || record.status === resultStatusEnum.resultCollegeUnPass"
                link type="danger" @click="deleteAlertEvent(record)" @dblclick.stop v-hasPermi="['mine:mine-horizontal:del']">
                删除</el-button>
              <!-- 打回需要通过角色控制显示，配置显示后，可在任意状态下打回 -->
              <el-button v-if="false" link type="danger" @click="repulseEvent(record)" @dblclick.stop v-hasPermi="['mine:mine-horizontal:reject']">打回</el-button>
            </template>

            <!-- 科研处 -->
            <template v-else-if="props.moduleType === 'office'">
              <el-button link type="primary" @click="detailEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:office:office-horizontal:detail']">详情</el-button>
              <el-button v-if="record.status === resultStatusEnum.resultCollegePassWaitOfficeAudit" link type="primary"
                @click="auditEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:office:office-horizontal:audit']">审核</el-button>
              <el-button v-if="hasRejectPermi" link type="danger"
                @click="repulseEvent(record)" @dblclick.stop>打回</el-button>
              <el-button  link type="primary"
                @click="recordEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:office:office-horizontal:auditRecord']">审核记录</el-button>
            </template>

            <!-- 学院 -->
            <template v-else-if="props.moduleType === 'college'">
              <el-button link type="primary" @click="detailEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:college:college-horizontal:detail']">详情</el-button>
              <!-- 打回需要通过角色控制显示，配置显示后，可在任意状态下打回 -->
              <el-button v-if="record.status === resultStatusEnum.resultWaitCollegeAudit" link type="primary"
                @click="auditEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:college:college-horizontal:audit']">审核</el-button>
              <el-button  link type="primary"
                @click="recordEvent(record)" @dblclick.stop v-hasPermi="['achievementReward:college:college-horizontal:auditRecord']">审核记录</el-button>
            </template>
          </div>
        </template>
      </TableForm>

      <!-- 提交 -->
      <DelConfirmModal v-if="showSubmitModal" :visible="showSubmitModal" text="是否确认提交？" ok-text="确定" ok-type="primary"
      @cancel="showSubmitModal = false" @ok="submitOkHandelEvent" />

       <!-- 删除 -->
       <DelConfirmModal v-if="showDelModal" :visible="showDelModal" text="确定删除该条数据吗？" ok-text="删除"
        @cancel="() => showDelModal = false" @ok="deleteOkHandle" />

      <!-- 通过/不通过 -->
      <AuditModal v-if="showAuditModal" :visible="showAuditModal" @ok="auditOkHandle" @cancel="auditCancelHandle"
        @close="showAuditModal = false"></AuditModal>

      <!-- 打回 -->
      <RepulseModal v-if="showRepulseModal" :visible="showRepulseModal" @ok="repulseOkHandle"
        @close="showRepulseModal = false"></RepulseModal>

      <!-- 审核记录 -->
      <AuditRecordDrawer  v-if="showRecordDrawer" v-model:visible="showRecordDrawer" :project-id="currentRow?.id"></AuditRecordDrawer>

      <!-- 附件 -->
      <ResultAttachmentModal :file-list="attachmentFileList" v-if="showAttachmentModal"
        @close="showAttachmentModal = false" :visible="showAttachmentModal"></ResultAttachmentModal>
    </div>
  </div>
</template>

<style scoped lang="scss">
.optionClass {
  margin-left: -8px;
  :deep(.el-button) {
    margin-left: 8px;
    padding: 0px;
  }
}
.status-box {
  display: flex;
  align-items: center;
  flex-direction: row;

  .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    margin-right: 8px;
  }

  .status-text {
    width: calc(100% - 14px);
  }
}

.deleteAlert {
  :deep(.el-overlay) {
    opacity: 0.3;
  }
}
</style>